import sys

import atom
import gdata.contacts.data
import gdata.contacts.client

user,  pwd = "garryya@gmail.com",  "sasdfsfAl#117*"

print "Bonjour GarCons !!!"
print "Connecting to Google Contacts of ",  user,  " ... "

client = gdata.client.GDClient( source = 'garryya-garcons' )
try:
    client.ClientLogin( user,  pwd,  client.source, "cp", "GOOGLE" )
except gdata.client.BadAuthentication as e:
    print "Cannot connect to GoogleContacts : bad authentication (",  e,  ")\n"
    sys.exit(1)
except gdata.client.ClientLoginFailed as e:
    print "Cannot connect to GoogleContacts : ClientLoginFailed (",  e,  ")\n"
    sys.exit(1)
except gdata.client.ClientLoginTokenMissing as e:
    print "Cannot connect to GoogleContacts : ClientLoginTokenMissing (",  e,  ")\n"
    sys.exit(1)
except gdata.client.CaptchaChallenge as e:
    print "Cannot connect to GoogleContacts : CaptchaChallenge (",  e,  ")\n"
    sys.exit(1)
except  BaseException as e:
    print "Cannot connect to GoogleContacts : unknown reason (", e,")\n"
    sys.exit(1)
    
print "Connected."

feed = client.get_feed( "https://www.google.com/m8/feeds/contacts/default/full" )

print feed
    
print "Finished."
    
